package com.lst.api.vo;

import com.lst.api.entity.LoanInfo;
import com.lst.api.exception.RequestParamErrorException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 贷款信息表
 *
 * @author Frank
 * @date 2019-12-30 10:31:37
 * @version: V1.0
 */
@Data
@NoArgsConstructor
public class LoanInfoVo implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(name = "loanBankId", value = "贷款银行id", required = true, dataType = "Long")
    private Long loanBankId;

    @ApiModelProperty(name = "loanAmount", value = "贷款金额，单位元", required = true, dataType = "Double")
    private Double loanAmount;

    @ApiModelProperty(name = "surplusAmount", value = "剩余本金", required = true, dataType = "Double")
    private Double surplusAmount;

    @ApiModelProperty(name = "overdueId", value = "逾期情况id", required = true, dataType = "Long")
    private Long overdueId;

    public LoanInfoVo(LoanInfo loanInfo) {
        if (loanInfo == null) {
            return;
        }
        this.loanBankId = loanInfo.getLoanBankId();
        this.loanAmount = loanInfo.getLoanAmount();
        this.surplusAmount = loanInfo.getSurplusAmount();
        this.overdueId = loanInfo.getOverdueId();
    }

    public void check() {
        boolean check = this.loanBankId != null
                && this.loanAmount != null
                && this.surplusAmount != null
                && this.overdueId != null;
        if (!check) {
            throw new RequestParamErrorException("LoanInfoVo请求参数不合法！");
        }
    }

    public boolean isAllFieldNull() {
        return this.loanBankId == null
                && this.loanAmount == null
                && this.surplusAmount == null
                && this.overdueId == null;
    }

}